Skip to content

Add run meta stats to artifacts - #191

Merged
azchin merged 4 commits into
ossf:mainfrom
tusharshah21:feat/run-meta-stats
Jun 1, 2026
Merged

azchin merged 4 commits into
ossf:mainfrom
tusharshah21:feat/run-meta-stats

Conversation

@tusharshah21

Copy link
Copy Markdown
Contributor

Summary

Added run-level statistics capture and persistence so each run writes a meta.json under its run directory, then exposed that metadata through the artifacts command output.

This was done to satisfy the issue requirement to track and retrieve:

  • LLM credits used
  • POVs found
  • Seeds shared
  • Number of builds requested through libCRS

User Impact

  • User-facing change
  • Internal-only change

CLI/API/config/docs impact and migration:

  • CLI output change: artifacts JSON now includes a top-level meta object when resolving a run.
  • No new required flags and no command rename/removal.
  • Existing consumers that ignore unknown JSON fields continue to work.
  • Consumers with strict JSON schema validation should allow the new optional meta field.

Release Note / Changelog

  • I updated CHANGELOG.md ([Unreleased]) for user-facing changes
  • No changelog entry needed (internal-only refactor/test/chore)

Deprecation or breaking behavior:

  • None.
  • No replacement path needed.
  • No planned removal window.

Validation

  • Added/updated unit test coverage for artifacts meta output behavior.
  • Ran static diagnostics on changed files with no reported errors.
  • Attempted targeted pytest run for the updated artifacts test module, but local execution in this Windows environment is blocked during collection by a Linux-only fcntl import dependency.

Checklist

  • I followed Conventional Commits
  • I updated docs for behavior/config/CLI changes
  • I added/updated tests for behavior changes
  • I considered backward compatibility and migration impact

Closes #80

@azchin azchin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, could change the meta.json format to something like the snippet below? There's additional implementation change requests commented.

Also please sign your commits and use Conventional Commits for commit messages.

{
  "totals": {
    "artifacts": {
      "povs": 2,
      "seeds": 4,
      "patches": 1,
      "bug_candidates": 2
    },
    "llm": {
      "credits_used": 1.65
    },
    "sidecar": {
      "patch_builds": 4,
      "patch_tests": 2,
      "pov_runs": 8
    }
  },
  "crs": {
    "crs_a": {
      "artifacts": {
        "povs": 2,
        "seeds": 3,
        "patches": 1,
        "bug_candidates": 0
      },
      "llm": {
        "credits_used": 1.25
      },
      "sidecar": {
        "patch_builds": 4,
        "patch_tests": 2,
        "pov_runs": 7
      }
    }
  }
}

Comment thread oss_crs/src/crs_compose.py Resolved
Comment thread oss_crs/src/crs_compose.py Resolved
Comment thread oss_crs/src/crs_compose.py Resolved
Comment thread oss_crs/src/crs_compose.py Resolved
@tusharshah21

Copy link
Copy Markdown
Contributor Author

schema update to nested totals + per-CRS (patches, bug_candidates), structured JSONL metrics replacing log scraping, LiteLLM spend polling via /global/spend/report, and artifact counting centralized in WorkDir are all clean and cohesive enough to ship as one PR. CI green, no split needed.
Let me know if there are any other suggestion!

@azchin azchin left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added suggestions to get LiteLLM reporting working. Tracking number of artifacts and libCRS calls look good.

Again, please sign-off your commits https://github.com/ossf/oss-crs/pull/191/checks?check_run_id=75833728185.
The easiest way to do this is probably interactive rebase, and selectively reword your commits to manually add the Signed-off-by: Author Name <authoremail@example.com> for each of your changes.

Comment thread oss-crs-infra/litellm-key-gen/main.py Resolved
Comment thread oss-crs-infra/litellm-key-gen/main.py Resolved
@azchin

azchin commented May 28, 2026

Copy link
Copy Markdown
Collaborator

Hello @tusharshah21 , just checking in on whether you would like to continue working on this PR. If you no longer have bandwidth or interest that's totally fine, I will close this PR and build upon your contribution in my own branch.

@tusharshah21

tusharshah21 commented May 29, 2026 •

Copy link
Copy Markdown
Contributor Author

ofcourse wanted to finish it man, was occupied with work, would try to cover it within weekend. Cheers!

@tusharshah21
tusharshah21 force-pushed the feat/run-meta-stats branch from a1c22d8 to 55fb199 Compare May 31, 2026 14:43
@tusharshah21

Copy link
Copy Markdown
Contributor Author

Applied all suggestions:

  • Switched from /global/spend/report to per-key /key/info queries so spend values read correctly from plaintext keys
  • Replaced atomic rename in write_spend_summary with a direct write to fix the cross-filesystem failure
  • Updated the polling loop to use collect_spend_summary directly

my bad for delays covered the suggestion but

Signed-off-by: tusharshah21 <tusharkumarshah14394@gmail.com>
Signed-off-by: tusharshah21 <tusharkumarshah14394@gmail.com>
…bles

Signed-off-by: tusharshah21 <tusharkumarshah14394@gmail.com>
…tion

Signed-off-by: tusharshah21 <tusharkumarshah14394@gmail.com>
@azchin
azchin force-pushed the feat/run-meta-stats branch from 55fb199 to e6445dd Compare June 1, 2026 20:40
@azchin

azchin commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

Awesome, meta stats from oss-crs artifacts look good and LLM credits are properly reported now!

@azchin
azchin merged commit 3c9feee into ossf:main Jun 1, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feat: Run Session Statistics

2 participants